/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package harjoitukset;

import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import javax.swing.JApplet;
import javax.swing.JPanel;

/**
 *
 * @author f0899
 */
public class Tehtava1 extends JApplet {

    private int x, y; // hiiren koordinaatit

    public void init() {
        // kuuntelija hiirelle
        addMouseMotionListener(new HiirenTarkkailija());
        getContentPane().add(new PiirtoPinta());
    }

    class HiirenTarkkailija extends MouseMotionAdapter {

        public void mouseMoved(MouseEvent event) {
            x = event.getX();
            y = event.getY();
            repaint();
        }
    }

    class PiirtoPinta extends JPanel {

        public void paintComponent(Graphics g) {
            g.drawString(x + "," + y, x, y);
        }
    }
}
